import request from '@/utils/request'
import { transformQueryCondition } from '@/utils'
// import qs from 'qs'
// 插入
export function insertItem(data) {
  return request({
    url: '/uums/SysUserInfo/insertUserAndPtOrg',
    method: 'POST',
    data: data
  })
}

// 批量插入
export function batchInsertItem(data) {
  return request({
    url: '/uums/OzOrgUserinfo/batch',
    method: 'POST',
    data: data
  })
}

// 复合检索
export function compositeSelect(query) {
  // const searchCon = qs.stringify(query)
  return request({
    url: '/uums/common/user/getUserInfo',
    method: 'POST',
    params: { userId: query.id }
  })
}
// 查询兼职机构
export function partJobSelect(query) {
  const searchCon = transformQueryCondition(query)
  return request({
    url: '/uums/common/user/getUserPtOrgInfo?userId=' + query.id,
    method: 'POST',
    data: searchCon
  })
}

// 求件
export function countSelect(query) {
  const searchCon = transformQueryCondition(query)
  return request({
    url: '/uums/OzOrgUserinfo/count',
    method: 'POST',
    data: searchCon
  })
}

// 强制删除
export function forceDeleteItem(data) {
  return request({
    url: '/uums/OzOrgUserinfo/force',
    method: 'DELETE',
    data: data
  })
}

// 批量强制删除
export function batchDeleteItem(data) {
  return request({
    url: '/uums/OzOrgUserinfo/force/batch',
    method: 'DELETE',
    data: data
  })
}

// 检索
export function select(query) {
  const searchCon = transformQueryCondition(query)
  return request({
    url: '/uums/OzOrgUserinfo/select',
    method: 'POST',
    data: searchCon
  })
}

// 更新
export function updateItem(id, data) {
  return request({
    url: '/uums/SysUserInfo/updateUserAndPtOrg/' + id,
    method: 'POST',
    data: data
  })
}

// 检索
export function selectSysSubsys(query) {
  const searchCon = transformQueryCondition(query)
  return request({
    url: '/uums/SysSubsys/select',
    method: 'POST',
    data: searchCon
  })
}

// 检索
export function selectMenuTree(id) {
  return request({
    url: '/uums/tree/menu/*/*/*/' + id,
    method: 'POST'
  })
}

// 组织机构Tree
export function getOrgTree() {
  return request({
    url: '/uums/tree/org',
    method: 'POST'
  })
}

// 检索未设置角色人员
export function secretarySelected(data) {
  let searchCon = transformQueryCondition(data)
  delete searchCon.userId
  return request({
    url: '/uums/SysUserInfo/secretarySelected/?managerId=' + data.managerId + '&isExist='+data.isExist,
    method: 'POST',
    data: searchCon
  })
}

// 批量插入秘书
export function batchInsertItemSecretary(data) {
  return request({
    url: '/uums/SysManagerSecretary/batch',
    method: 'POST',
    data: data
  })
}

// 删除
export function deleteHandle(query) {
  return request({
    url: '/uums/SysManagerSecretary/force/batch',
    method: 'DELETE',
    data: query
  })
}
